<template>
  <page-header-wrapper>
    <page-tab-list> </page-tab-list>

    <a-card :border="false">
      <a-form-model
        ref="ruleForm"
        :model="form"
        :rules="formRules"
        :label-col="{ span: 3 }"
        :wrapper-col="{ span: 21 }"
      >
        <!-- <h3 class="title">活动设置</h3>
        <a-form-model-item
          label="商品分销"
          prop="name"
          extra="注：必须现在“分销中心=>分销设置=>基础设置”中设置，才能使用"
        >
          <a-radio-group name="radioGroup" :default-value="0">
            <a-radio :value="1"> 开启 </a-radio>
            <a-radio :value="0"> 关闭 </a-radio>
          </a-radio-group>
        </a-form-model-item>
        
        <a-form-model-item
          label="短信提醒"
          prop="name"
          extra="注：必须现在“商城管理=>短信通知”中设置，才能使用"
        >
          <a-radio-group name="radioGroup" :default-value="0">
            <a-radio :value="1"> 开启 </a-radio>
            <a-radio :value="0"> 关闭 </a-radio>
          </a-radio-group>
        </a-form-model-item>
        
        <a-form-model-item
          label="邮件提醒"
          prop="name"
          extra="注：必须现在“商城管理=>邮件通知”中设置，才能使用"
        >
          <a-radio-group name="radioGroup" :default-value="0">
            <a-radio :value="1"> 开启 </a-radio>
            <a-radio :value="0"> 关闭 </a-radio>
          </a-radio-group>
        </a-form-model-item>

        <a-form-model-item
          label="订单打印"
          prop="name"
          extra="注：必须现在“商城管理=>小票打印=>打印设置”中设置，才能使用"
        >
          <a-radio-group name="radioGroup" :default-value="0">
            <a-radio :value="1"> 开启 </a-radio>
            <a-radio :value="0"> 关闭 </a-radio>
          </a-radio-group>
        </a-form-model-item>

        <a-form-model-item
          label="区域购买"
          prop="name"
          extra="注：必须现在“商城管理=>区域允许购买”中设置，才能使用"
        >
          <a-radio-group name="radioGroup" :default-value="0">
            <a-radio :value="1"> 开启 </a-radio>
            <a-radio :value="0"> 关闭 </a-radio>
          </a-radio-group>
        </a-form-model-item>

        <a-form-model-item
          label="退款方式"
          prop="name"
        >
          <a-radio-group name="radioGroup" :default-value="0">
            <a-radio :value="1"> 开启 </a-radio>
            <a-radio :value="0"> 关闭 </a-radio>
          </a-radio-group>
        </a-form-model-item>

        <a-form-model-item
          label="详情提示"
          prop="name"
        >
          <a-radio-group name="radioGroup" :default-value="0">
            <a-radio :value="1"> 开启 </a-radio>
            <a-radio :value="0"> 关闭 </a-radio>
          </a-radio-group>
        </a-form-model-item>

        <a-form-model-item
          label="提示内容"
          prop="name"
        >
          <a-input v-model="form.name" placeholder="请输入" class="maxWidth"></a-input>
        </a-form-model-item> -->

        <div class="title">活动规则设置</div>
        <a-divider />
        <a-form-model-item label="活动规则" prop="desc">
          <a-textarea
            class="maxWidth"
            v-model="form.desc"
            placeholder="请输入"
            :auto-size="{ minRows: 3, maxRows: 5 }"
          ></a-textarea>
        </a-form-model-item>
      </a-form-model>
      <a-row>
        <a-col :span="3"></a-col>
        <a-col :span="21">
          <a-button :loading="confirmLoading" type="primary" @click="submit">保存</a-button>
        </a-col>
      </a-row>
    </a-card>
  </page-header-wrapper>
</template>

<script>
import pt from '@/api/pt'
export default {
  data() {
    return {
      form: {
        desc: '',
      },
      formRules: {
        desc: [{ required: true, trigger: 'blur', message: '请输入活动规则' }],
      },
      confirmLoading: false
    }
  },
  created() {
    this.getData()
  },
  methods: {
    async getData() {
      const res = await pt.ptGetArticle()
      this.form = res.data
    },
    submit() {
      this.confirmLoading = true
      this.$refs.ruleForm.validate(async (valid) => {
        if (valid) {
          const res = await pt.ptSaveAritcle(this.form)
          res.code == 0 && this.$message.success('保存成功')
          this.getData()
          this.confirmLoading = false
        } else {
          this.confirmLoading = false
          console.log('error submit!!')
          return false
        }
      })
    },
  },
}
</script>

<style lang="scss" scoped>
.title {
  font-size: 16px;
  color: rgba(0, 0, 0, 0.85);
  margin-bottom: 14px;
  font-weight: bold;
}
.maxWidth {
  max-width: 480px;
}
</style>
